package com.zb.kl.common.exceptions;

public class StatusCodeException extends RuntimeException {
    private final StatusCode statusCode;

    public StatusCodeException(StatusCode statusCode, String message) {
        super(message);
        this.statusCode = statusCode;
    }

    public StatusCodeException(StatusCode statusCode, String message, Exception e) {
        super(message, e);
        this.statusCode = statusCode;
    }

    public static StatusCodeException error(StatusCode statusCode, String message) {
        return new StatusCodeException(statusCode, message);
    }

    public static StatusCodeException error(StatusCode statusCode, String message, Exception e) {
        return new StatusCodeException(statusCode, message, e);
    }

    public StatusCode getStatusCode() {
        return statusCode;
    }

    public int getCode() {
        return statusCode.getCode();
    }

    public String getStatusCodeMsg() {
        return statusCode.getMessage();
    }
}
